
package ProOF.apl.problems.real.functions;

import ProOF.com.LinkerParameters;
import java.lang.Math;
/**
 *
 * @author Lucas
 */
public class RealFuncHV extends aRealFunction{
	
	
	@Override
	public void parameters(LinkerParameters link) throws Exception {

	}
	
	@Override
	public int dimension() {
		return 3;
	}
	
	@Override
	public double min( int i ) {
		return -10;
	}
	
	@Override
	public double max( int i ) {
		return 10;
	}

	@Override
	public double f(double[] x) throws Exception {
		check(x);
		double theta;
		if (x[0] >= 0) {
			theta = 1/(2*Math.PI)* Math.atan(x[1]/x[0]);
		}else{
			theta = 1/(2*Math.PI)* Math.atan((x[1]/x[0]) + 0.5);
		}
		
		return 100*(Math.pow((x[1] - 10*theta), 2) + Math.pow((Math.sqrt(x[0]*x[0] + x[1]*x[1])
					- 1), 2) + x[2]*x[2] );
	}

	@Override
	public String name() {
		return "HV";
	}

	@Override
	public String description() {
		return "Helical Valley Problem";
	}	
}
